package com.chengqj.blogweb.blog.repo.dao;

import com.chengqj.blogweb.blog.repo.pojo.TBlogRecommend;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface TBlogRecommendMapper {
    @Delete({
        "delete from t_blog_recommend",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into t_blog_recommend (title, blog_id)",
        "values (#{title,jdbcType=VARCHAR}, #{blogId,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(TBlogRecommend record);

    @Select({
        "select",
        "id, title, blog_id",
        "from t_blog_recommend",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="blog_id", property="blogId", jdbcType=JdbcType.INTEGER)
    })
    TBlogRecommend selectByPrimaryKey(Integer id);

    @Select({
        "select",
        "id, title, blog_id",
        "from t_blog_recommend"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="blog_id", property="blogId", jdbcType=JdbcType.INTEGER)
    })
    List<TBlogRecommend> selectAll();

    @Update({
        "update t_blog_recommend",
        "set title = #{title,jdbcType=VARCHAR},",
          "blog_id = #{blogId,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(TBlogRecommend record);
}